file_path = 'a.txt'
with open('a.txt', 'r', encoding='utf-8', errors='replace') as file:
    line_count = len(file.readlines())
print("方法1 - 文本文件的行数:", line_count)

test = []
num = 1
str = ""
with open('a.txt', 'r', encoding='utf-8', errors='replace') as file:
    content = file.readlines()
    for i in range(line_count):
        if((i+1)%3 == 2):
            str = content[i][:-1] + "-"
        if(not((i+1)%3)):
            test.append(str + content[i][:-1])
            test.append("\n")

with open("result.txt", "w") as file:
    file.writelines(test)    
    





